import json
import packer
import utils

print ("Hello, tourist! It is the knapsack packing system prototype\n")

# read pool of items from file in JSON format
f = open('./pool.js', 'r')
pool = f.read()
f.close

# JSON decode pool
pool = json.loads(pool)

# for i, v in enumerate(pool):
#     v['id'] = i

# packing (pack this fucking stuff!)

knapsack = packer.genetic(pool, 10000)
print ("Genetic, Result: ")
utils.show(knapsack)                      

knapsack = packer.bb(pool, 10000)
print ("Brench and bound, Result: ")
utils.show(knapsack)

# knapsack = packer.wrongbb(pool, 10000)
# print ("WRONG approach to brench and bound, Result: ")
# utils.show(knapsack)
     
# JSON encode this fucking stuff
knapsack = json.dumps(knapsack)

# write pool of items from file in JSON format
f = open('./knapcack.js', 'w')
f.write(knapsack)
f.close

# fucking packing done
print ("Your knapsack is ready, take it!")
